#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
const int MAXN=400;
string s;
int main(void){
    while(getline(cin,s)){
        if(s[0]=='#'){
            break;
        }
        int n=s.size();
        long long sum=0;
        for(int i=0;i<n;i++){
            if(s[i]==' '){
                continue;
            }
            else{
                sum+=(i+1)*(s[i]-'A'+1);
            }
        }
        printf("%lld\n",sum);
    }
    return 0;
}